package com.chinacoal.hr.levelapi.client;

import com.chinacoal.hr.levelapi.client.fallback.ApprovalClientFallback;
import com.chinacoal.hr.levelapi.client.response.Result;
import com.chinacoal.hr.levelapi.entity.AttendanceAppeal;
import com.chinacoal.hr.levelapi.entity.BizTravel;
import com.chinacoal.hr.levelapi.entity.LeaveRecord;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.ApiParam;
import org.springframework.cloud.openfeign.FeignAutoConfiguration;
import org.springframework.cloud.openfeign.FeignClient;
import org.springframework.web.bind.annotation.*;

/**
 * Created by jinyabin on 2020/10/29.
 */
@Api(tags = {"专门提供审批"})
@FeignClient(name = "ccip-hr-attendance",configuration = FeignAutoConfiguration.class,fallback = ApprovalClientFallback.class)
public interface ApprovalClient {


    /**
     * 根据流程实例ID查询待审批的出差申请单
     *
     * @param insCode : 流程实例ID
     * @return : com.chinacoal.hr.levelapi.response.Result
     * @author : YunTao.Li
     * @date : 2019/11/27 2019/11/27
     */
    @ResponseBody
    @GetMapping("/approve/travel/{insCode}")
    @ApiOperation(value = "查询待审批的出差申请信息")
    public Result travelInfo(@ApiParam("出差申请单编码") @PathVariable String insCode);


    /**
     * 审批通过出差申请单
     *
     * @param travelId :
     * @param record   :
     * @return : com.chinacoal.hr.levelapi.response.Result
     * @author : YunTao.Li
     * @date : 2019/11/27 2019/11/27
     */
    @PutMapping("/approve/travel/{travelId}/approvaled")
    @ApiOperation(value = "审批通过出差申请单")
    public Result travelApprove(@PathVariable String travelId,
                                @RequestBody BizTravel record);



    /**
     * 驳回出差申请单
     *
     * @param travelId :
     * @param record   :
     * @return : com.chinacoal.hr.levelimpl.response.Result
     * @author : YunTao.Li
     * @date : 2019/12/18 2019/12/18
     */
    @PutMapping("/approve/travel/{travelId}/disagree")
    @ApiOperation(value = "驳回出差申请单")
    public Result travelApproveDisagree(@PathVariable String travelId,
                                        @RequestBody BizTravel record);



    /**
     * 根据考勤申诉表编码查询待审批的考勤申诉信息
     *
     * @param insCode : 流程实例ID
     * @return : com.chinacoal.hr.levelapi.response.Result
     * @author : YunTao.Li
     * @date : 2019/11/27 2019/11/27
     */
    @ResponseBody
    @GetMapping("/approve/appeal/{insCode}")
    @ApiOperation(value = "查询待审批的考勤申诉信息")
    public Result appealInfo(
            @ApiParam("考勤申诉单编码") @PathVariable String insCode);



    /**
     * 审批通过考勤申诉单
     *
     * @param explainId        :
     * @param attendanceAppeal :
     * @return : com.chinacoal.hr.levelapi.response.Result
     * @author : YunTao.Li
     * @date : 2019/11/27 2019/11/27
     */
    @PutMapping("/approve/appeal/{explainId}/approvaled")
    @ApiOperation(value = "审批通过考勤申诉单")
    public Result appealApprove(@PathVariable String explainId,
                                @RequestBody AttendanceAppeal attendanceAppeal);



    /**
     * 驳回考勤申诉单
     *
     * @param explainId        :
     * @param attendanceAppeal :
     * @return : com.chinacoal.hr.levelimpl.response.Result
     * @author : YunTao.Li
     * @date : 2019/12/18 2019/12/18
     */
    @PutMapping("/approve/appeal/{explainId}/disagree")
    @ApiOperation(value = "审批驳回考勤申诉单")
    public Result appealApproveDisagree(@PathVariable String explainId,
                                        @RequestBody AttendanceAppeal attendanceAppeal);





    /**
     * 获得请假单基本信息
     *
     * @param insCode : 流程实例编码
     * @return : com.chinacoal.hr.levelapi.response.Result
     * @author : YunTao.Li
     * @date : 2019/11/28 2019/11/28
     */
    @ResponseBody
    @GetMapping("/approve/leave/{insCode}")
    @ApiOperation(value = "查询待审批的请假单")
    public Result leaveInfo(
            @ApiParam("请假单编码") @PathVariable String insCode);



    /**
     * 审批通过请假单
     *
     * @param leaveId :
     * @param record  :
     * @return : com.chinacoal.hr.levelapi.response.Result
     * @author : YunTao.Li
     * @date : 2019/11/28 2019/11/28
     */
    @PutMapping("/approve/leave/{leaveId}/approvaled")
    @ApiOperation(value = "审批通过请假单")
    public Result leaveApprove(@PathVariable String leaveId,
                               @RequestBody LeaveRecord record);




    /**
     * 驳回请假单
     *
     * @param leaveId :
     * @param record  :
     * @return : com.chinacoal.hr.levelimpl.response.Result
     * @author : YunTao.Li
     * @date : 2019/12/18 2019/12/18
     */
    @PutMapping("/approve/leave/{leaveId}/disagree")
    @ApiOperation(value = "审批驳回请假单")
    public Result leaveApproveDisagree(@PathVariable String leaveId,
                                       @RequestBody LeaveRecord record);



    @ResponseBody
    @GetMapping("/approve/historys/{processInstID}")
    @ApiOperation(value = "查询审批历史")
    public Result historys( @PathVariable @ApiParam("流程实例ID") String processInstID,
                            @ApiParam("单据编号") Object data);




}
